﻿using HardcoreGame.Common.Players;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ModLoader;
namespace HardcoreGame.Content.Buffs
{
    public class Thirst : ModBuff
    {
        private int timer = 0;
        private const int interval = 60;
        public override void SetStaticDefaults()
        {
            Main.debuff[Type] = true;
            Main.buffNoTimeDisplay[Type] = false;
        }

        public override void Update(Player player, ref int buffIndex)
        {
            timer++;
            ThirstPlayer thirstPlayer = player.GetModPlayer<ThirstPlayer>();
            int stage = thirstPlayer.StageForThirst;
            switch (stage)
            {
                case 5:
                    player.moveSpeed *= 0.9f;
                    player.jumpSpeedBoost *= 0.9f;
                    break;
                case 6:
                    player.moveSpeed *= 0.8f;
                    player.jumpSpeedBoost *= 0.8f;
                    break;
                case 7:
                    player.moveSpeed *= 0.7f;
                    player.jumpSpeedBoost *= 0.7f;
                    player.GetAttackSpeed(DamageClass.Generic) *= 0.9f;
                    break;
                case 8:
                    player.moveSpeed *= 0.6f;
                    player.jumpSpeedBoost *= 0.6f;
                    player.GetDamage(DamageClass.Generic) *= 0.9f;
                    break;
                case 9:
                    player.moveSpeed *= 0.5f;
                    player.jumpSpeedBoost *= 0.5f;
                    if (timer >= interval)
                    {
                        int lifeReduction = 2;
                        player.statLife -= lifeReduction;
                        if (player.statLife < 0)
                        {
                            player.statLife = 0;
                        }
                        CombatText.NewText(player.getRect(), Color.Red, lifeReduction, true);
                        timer = 0;
                    }
                    player.GetDamage(DamageClass.Generic) *= 0.8f;
                    break;
                case 10:
                    player.moveSpeed *= 0.2f;
                    player.jumpSpeedBoost *= 0.2f;
                    if (timer >= interval)
                    {
                        int lifeReduction1 = 5;
                        player.statLife -= lifeReduction1;
                        if (player.statLife < 0)
                        {
                            player.statLife = 0;
                        }
                        CombatText.NewText(player.getRect(), Color.Red, lifeReduction1, true);
                        timer = 0;
                    }
                    player.GetDamage(DamageClass.Generic) *= 0.6f;
                    break;
            }
        }

    }
}
